<include file="public@head" />
</head>

<body>
    <div class="layui-fluid wrap js-check-wrap" id="component-tabs">
        <div class="layui-row">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">部门分类</div>
                    <div class="layui-card-body">
                        <div class="layui-tab">
                            <ul class="layui-tab-title">
                                <li class="layui-this"><a href="{:url('Group/index')}">部门管理</a></li>
                                <li><a href="{:url('Group/add')}">添加部门</a></li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <form class="layui-form" method="post" action="{:url('Group/index')}">
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">部门名称:</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="keyword" required lay-verify="required" placeholder="请输入部门名称" autocomplete="off" class="layui-input" value="{$keyword|default=''}">
                                            </div>
                                            <input type="submit" class="layui-btn layui-btn-normal" value="搜索" />
                                            <a class="layui-btn layui-btn-danger" href="{:url('Group/index')}">清空</a>
                                        </div>
                                    </form>
                                    <form method="post" class="js-ajax-form layui-form" action="{:url('Group/listOrder')}">
                                        <div class="layui-btn-group">
                                            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm js-ajax-submit">{:lang('SORT')}</button>
                                            <button class="layui-btn layui-btn-normal layui-btn-sm js-ajax-submit" type="submit" data-action="{:url('Group/toggle',array('display'=>'1'))}" data-subcheck="true">
                                                {:lang('DISPLAY')}
                                            </button>
                                            <button class="layui-btn layui-btn-normal layui-btn-sm js-ajax-submit" type="submit" data-action="{:url('Group/toggle',array('hide'=>1))}" data-subcheck="true">{:lang('HIDE')}
                                            </button>
                                        </div>
                                        <empty name="keyword">
                                            <table class="layui-table" id="menus-table">
                                                <colgroup>
                                                    <col width="35">
                                                    <col width="60">
                                                    <col width="20">
                                                    <col>
                                                    <col>
                                                    <col width="30">
                                                    <col width="220">
                                                </colgroup>
                                                <thead>
                                                    <tr>
                                                        <th>
                                                            <input lay-skin="primary" type="checkbox" lay-filter="js-check-all" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                                                        </th>
                                                        <th>ID</th>
                                                        <th>部门名称</th>
                                                        <th>添加时间</th>
                                                        <th>状态</th>
                                                        <th>操作</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    {$group_tree}
                                                </tbody>
                                            </table>
                                            <else />
                                            <table class="layui-table">
                                                <colgroup>
                                                    <col width="35">
                                                    <col width="60">
                                                    <col width="20">
                                                    <col>
                                                    <col>
                                                    <col width="30">
                                                    <col width="220">
                                                </colgroup>
                                                <thead>
                                                    <tr>
                                                        <th>
                                                            <input lay-skin="primary" lay-filter="js-check-all" type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                                                        </th>
                                                        <th>ID</th>
                                                        <th>部门名称</th>
                                                        <th>添加时间</th>
                                                        <th>状态</th>
                                                        <th>操作</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <foreach name="categories" item="vo">
                                                        <tr>
                                                            <td>
                                                                <input lay-skin="primary" type="checkbox" lay-filter="js-check" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" value="{$vo.id}">
                                                            </td>
                                                            <td>{$vo.id}</td>
                                                            <td>{$vo.name}</td>
                                                            <td>{$vo.description}</td>
                                                            <td>{$vo.status?'显示':'隐藏'}</td>
                                                            <td>
                                                                <a class="layui-btn layui-btn-normal" href="{:url('Group/add', ['parent' => $vo.id])}">添加子部门</a>
                                                                <a class="layui-btn layui-btn-normal" href="{:url('Group/edit',['id'=>$vo.id])}">编辑</a>
                                                                <a class="layui-btn layui-btn-normal js-ajax-delete" href="{:url('Group/delete',['id'=>$vo.id])}">删除</a>
                                                                <empty name="vo.status">
                                                                    <a class="layui-btn layui-btn-normal js-ajax-dialog-btn" data-msg="您确定显示此部门吗" href="{:url('Group/toggle',['ids'=>$vo.id,'display'=>1])}">显示</a>
                                                                    <else />
                                                                    <a class="layui-btn layui-btn-normal js-ajax-dialog-btn" data-msg="您确定隐藏此部门吗" href="{:url('Group/toggle',['ids'=>$vo.id,'hide'=>1])}">隐藏</a>
                                                                </empty>
                                                            </td>
                                                        </tr>
                                                    </foreach>
                                                </tbody>
                                            </table>
                                        </empty>
                                        <div class="layui-btn-group">
                                            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm js-ajax-submit">{:lang('SORT')}</button>
                                            <button class="layui-btn layui-btn-normal layui-btn-sm js-ajax-submit" type="submit" data-action="{:url('Group/toggle',array('display'=>'1'))}" data-subcheck="true">
                                                {:lang('DISPLAY')}
                                            </button>
                                            <button class="layui-btn layui-btn-normal layui-btn-sm js-ajax-submit" type="submit" data-action="{:url('Group/toggle',array('hide'=>1))}" data-subcheck="true">{:lang('HIDE')}
                                            </button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <include file="public@footer" />
    <script>
    $(document).ready(function() {
        Wind.css('treeTable');
        Wind.use('treeTable', function() {
            $("#menus-table").treeTable({
                indent: 20,
                initialState: 'expanded'
            });
        });
    });
    </script>
</body>

</html>